# Recipe file for xcip.
#
# Maintainers: (C) 2016 Mateus P. Rodrigues, mprodrigues@dragora.org.
#
# Under the terms of the GNU General Public License.

program=xclip
version=0.13
release=1
packagename=xclip
packageversion=0.13

description="
xclip is a command line utility that is designed to run on any system
with an X11 implementation. It provides an interface to X selections
("the clipboard") from the command line. It can read data from
standard in or a file and place it in an X selection for pasting into
other X applications. xclip can also print an X selection to standard
out, which can then be redirected to a file or another program.
"

homepage=https://github.com/astrand/xclip
license=GPLv2

tarname=${version}.tar.gz

# Remote source(s)
fetch=https://github.com/astrand/xclip/archive/$tarname

# Parallel jobs for the compiler
jobs=1

# Source documentation
docs="COPYING INSTALL README*"
docsdir="${docdir}/${program}-${version}"

build() {
    unpack "${tardir}/$tarname"

    cd "$srcdir"
    autoreconf
    ./configure CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args

    make -j${jobs}
    make -j${jobs} install DESTDIR="$destdir"
    make -j${jobs} install.man DESTDIR="$destdir"

    # Compress and link man pages (if needed)
    if [ -d "${destdir}/$mandir" ] ; then
	(
            cd "${destdir}/$mandir"
	    find . -type f -exec lzip -9 '{}' +
	    find . -type l | while read -r file
	    do
		ln -sf "$(readlink -- "$file").lz" "${file}.lz"
		rm -- "$file"
	    done
	)
    fi

    # Copy documentation
    mkdir -p "${destdir}${docsdir}"

    for file in $docs ; do
            cp -p $file "${destdir}${docsdir}"
	        done
}
